package fer

import "strings"

var labelMap = map[string]string{
	"GBP": "英镑",
	"HKD": "港币",
	"USD": "美元",
	"CHF": "瑞士法郎",
	"DEM": "德国马克",
	"FRF": "法国法郎",
	"SGD": "新加坡元",
	"SEK": "瑞典克朗",
	"DKK": "丹麦克朗",
	"NOK": "挪威克朗",
	"JPY": "日元",
	"CAD": "加拿大元",
	"AUD": "澳大利亚元",
	"EUR": "欧元",
	"MOP": "澳门元",
	"PHP": "菲律宾比索",
	"THB": "泰国铢",
	"NZD": "新西兰元",
	"KRW": "韩国元",
	"RUB": "俄罗斯卢布",
	"MYR": "马来西亚林吉特",
	"TWD": "新台币",
	"ESP": "西班牙比塞塔",
	"ITL": "意大利里拉",
	"NLG": "荷兰盾",
	"BEF": "比利时法郎",
	"FIM": "芬兰马克",
	"IDR": "印尼卢比",
	"BRL": "巴西里亚尔",
	"AED": "阿联酋迪拉姆",
	"INR": "印度卢比",
	"ZAR": "南非兰特",
	"SAR": "沙特里亚尔",
	"TRY": "土耳其里拉",
	"KZT": "哈萨克斯坦坚戈",
}

var codeMap = map[string][2]string{}

func init() {
	for code, label := range labelMap {
		codeMap[code] = [2]string{code, label}
		codeMap[label] = codeMap[code]
	}
	codeMap["€"] = codeMap["EUR"]
	codeMap["£"] = codeMap["GBP"]
	codeMap["￡"] = codeMap["GBP"]
	codeMap["$"] = codeMap["USD"]
	codeMap["美金"] = codeMap["USD"]
	codeMap["卢布"] = codeMap["RUB"]
	codeMap["林吉特"] = codeMap["MYR"]
	codeMap["泰铢"] = codeMap["THB"]
	codeMap["迪拉姆"] = codeMap["AED"]
	codeMap["港元"] = codeMap["HKD"]
	codeMap["澳币"] = codeMap["MOP"]
	codeMap["加元"] = codeMap["CAD"]
	codeMap["澳元"] = codeMap["AUD"]
	codeMap["韩元"] = codeMap["KRW"]
	codeMap["比索"] = codeMap["PHP"]
	codeMap["比塞塔"] = codeMap["ESP"]
	codeMap["沙亚币"] = codeMap["SAR"]
	codeMap["沙币"] = codeMap["SAR"]
	codeMap["SR"] = codeMap["SAR"]
	codeMap["里拉"] = codeMap["TRY"]
	codeMap["法郎"] = codeMap["CHF"]
	codeMap["克朗"] = codeMap["SEK"]
	codeMap["坚戈"] = codeMap["KZT"]
	codeMap["兰特"] = codeMap["ZAR"]
	codeMap["卢比"] = codeMap["INR"]
}

func GetCode(find string) string {
	return codeMap[strings.ToUpper(find)][0]
}

func GetLabel(find string) string {
	return codeMap[strings.ToUpper(find)][1]
}

func Codes() (codes []string) {
	for key := range codeMap {
		codes = append(codes, key)
	}
	return
}
